import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'stockFilter'
})
export class StockFilterPipe implements PipeTransform {

  transform(list: any[], field: string, keyWord: string): any {
    if (!field || !keyWord) {
      return list;
    } else {
      return list.filter(item => {
        let itemFieldValue = item[field].toLowerCase();
        return itemFieldValue.indexOf(keyWord) >= 0;
      })
    }
  }

}
